package com.lnking.lnkingplace.controller;


import com.lnking.common.http.ReturnResult;
import com.lnking.lnkingplace.model.dto.recordUser.RecordDetailDto;
import com.lnking.lnkingplace.model.dto.recordUser.RecordUserExportDto;
import com.lnking.lnkingplace.model.dto.recordUser.RecordUserSituationDto;
import com.lnking.lnkingplace.model.entity.Leaders;
import com.lnking.lnkingplace.model.request.leaders.LeadersAddRequest;
import com.lnking.lnkingplace.model.request.leaders.LeadersSearchRequest;
import com.lnking.lnkingplace.model.request.leaders.LeadersUpdateRequest;
import com.lnking.lnkingplace.model.request.record.user.RecordUserAddRequest;
import com.lnking.lnkingplace.model.request.record.user.RecordUserSearchRequest;
import com.lnking.lnkingplace.model.request.record.user.RecordUserUpdateRequest;
import com.lnking.lnkingplace.model.request.user.UserSearchRequest;
import com.lnking.lnkingplace.service.ILeadersService;
import com.lnking.starter.export.utils.ExportUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sn
 * @since 2022-09-03
 */
@Api(tags = "领导管理")
@RestController
@RequestMapping("/leaders")
public class LeadersController {

    @Autowired
    ILeadersService leadersService;

    @ApiOperation("新增")
    @PostMapping("/add")
    public ReturnResult add(@RequestBody @Valid LeadersAddRequest params) throws Exception {
        leadersService.add(params);
        return ReturnResult.success();
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public ReturnResult delete(@PathVariable("id") String id) {
        leadersService.removeById(id);
        return ReturnResult.success();
    }

    @ApiOperation("编辑")
    @PostMapping("/update")
    public ReturnResult update(@RequestBody @Valid LeadersUpdateRequest params) throws Exception {
        leadersService.update(params);
        return ReturnResult.success();
    }

    @ApiOperation("查询列表")
    @GetMapping("/list")
    public ReturnResult getList(LeadersSearchRequest params) {
        return ReturnResult.success(leadersService.pageList(params));
    }


    @ApiOperation("获取领导管理详情")
    @GetMapping("/{id}")
    public ReturnResult getDetail(@PathVariable("id") String id) {
        Leaders leaders = leadersService.getUserDetailById(id);
        return ReturnResult.success(leaders);
    }



}
